$NG.AllReady(function (page, { useDataIndexChange, useUpdateRow, useUpdateRows,useBeforeClick,useClick }) {
    getInDate()
    const grid = $NG.getCmpApi("p_form_nps_visit_record_d")
    const toolbar_dgrid = $NG.getCmpApi("toolbar_p_form_nps_visit_record_d");   
    toolbar_dgrid.insert({
        id: "template_download",
        text: "模板下载",
        iconCls: "icon-InsertRow"
    });
    $NG.updateState((updater)=>{
        updater.data.p_form_nps_visit_record_m.setProps({
            bill_name:`客户满意度回访`
        })
    })
    useClick(async function ({ args }) {
        const url = "http://nginx.clouddev.hisense.com/report/index.html#/tableDesign/TableManager/preview?rep_id=8570000000000019&multiCooperate=0&busCode=null&menucode=80415407-0c82-430a-b72e-26d549daf98c";
        // 打开报表并传递参数
        $NG.open(url, { AppTitle: "报表查看" });
      }, "template_download");
    console.log(`测试表体`, $NG.getCmpApi("p_form_nps_visit_record_d").getSelectedRow());
    $NG.updateUI((updater) => {
        const fields = ["u_skip"];
        console.log(updater, "qf");
        // fields.forEach((field) => {
            updater.editGrid.p_form_nps_visit_record_d.u_skip.setProps({
                // hidden: true, //隐藏
                // required: true, //必输
                disabled: false, //只读
            });
        // });
    });
    $NG.updateUI(updater => {
        updater.editGrid.p_form_nps_visit_record_d.u_skip.setProps((p) => {
            return {
                ...p, editor: {
                    ...p.editor,
                    onDoubleClick() {
                        const title = "回访问题确认-新增"
                        const origin = window.location.href.split("#")[0]
                        const arrD = grid.getRows()
                        let it = null;
                        const _tempArr = []
                        //找到选中的一行
                        arrD.forEach((item, index) => {
                            if (item.checked) {
                                _tempArr.push(index + 1)
                                it = item
                            }
                        })
                        if (it&&page.oType!='add') {
                            if (_tempArr.length > 1) {
                                $NG.alert('查看详细请勿选择多行！')
                            } else if (_tempArr.length == 1) {
                                console.log(`测试表体`, $NG.getCmpApi("p_form_nps_visit_record_d").getSelectedRow());
                                $NG.execServer("getHfwtqrBySourcePhid", { source_phid: $NG.getCmpApi("p_form_nps_visit_record_d").getSelectedRow().phid }, function (res) {
                                    console.log(res);
                                    if (res.count == 0) {
                                        console.log(`获取表体信息`, $NG.getPageState(), it)
                                        // const bookId = $NG.getPageState().data.p_form_visit_plan_m.phid
                                        // const bookName = $NG.getPageState().data.p_form_visit_plan_m.bill_name
                                        const param = `#/customform/detail?otype=add&busType=EFORM9000000122&isSso=1&AppTitle=${encodeURIComponent(title)}
                                                    &treePc=&treePcName=&phidName=${it.phid_pc_EXName}&phidPc=${it.phid_pc}&sourceId=${$NG.getCmpApi("p_form_nps_visit_record_d").getSelectedRow().phid}
                                                    &bookId=${$NG.getCmpApi("p_form_nps_visit_record_d").getSelectedRow().phid}&empName=${it.u_xmjl_EXName}&empPhid=${it.u_xmjl}&inType=click`
                                        $NG.open(origin + param)
                                    } else {
                                        const _data = JSON.parse(res.data)[0].extendObjects
                                        if (_data.app_status == 1) {
                                            console.log(`查看`);
                                            const datas = JSON.parse(res.data)[0].extendObjects
                                            const param = `#/customform/detail?id=${datas.phid}&otype=view&xbusType=EFORM9000000122&isSso=1&AppTitle=${encodeURIComponent("回访问题确认-查看")}
                                    &sourceId=${$NG.getCmpApi("p_form_nps_visit_record_d").getSelectedRow().phid}&inType=click`
                                            $NG.open(origin + param)

                                        } else {
                                            console.log(`修改`);
                                            const datas = JSON.parse(res.data)[0].extendObjects
                                            const param = `#/customform/detail?id=${datas.phid}&otype=edit&busType=EFORM9000000122&isSso=1&AppTitle=${encodeURIComponent("回访问题确认-修改")}
                                    &sourceId=${$NG.getCmpApi("p_form_visit_plan_d").getSelectedRow().phid}&inType=click`
                                            $NG.open(origin + param)

                                        }

                                    }
                                })

                            }
                        }
                        console.log('双击成功!!!!!', window.location.href);
                    }
                }
            }
        })
    })
    // setInterval(()=>{
    // console.log($NG.getCmpApi("p_form_nps_visit_record_d").getSelectedRow().phid);
    // },2000)
     //根据当前日期获取工作周期
     function getInDate(){
       $NG.execServer("getInDate", {}, function (res){
           if(res.count !==0){
               const _data = JSON.parse(res.data)[0].extendObjects
               $NG.updateState((updater)=>{
                   updater.data.p_form_nps_visit_record_m.setProps({
                       phid_cycle:{
                           label:_data.bill_name,
                           value:_data.phid
                       }
                   })
               })
           }
       })
     }
});